<template>
  <div class="main-container">
    <!-- 主要内容区域 -->
    <div class="content-container">
      <!-- 轮播图区域 -->
      <div class="carousel-section">
        <el-carousel :interval="4000" type="card" height="400px">
          <el-carousel-item v-for="(imgPath, index) in carouselImages" :key="index">
            <img :src="imgPath" alt="carousel image" class="carousel-img" />
          </el-carousel-item>
        </el-carousel>
      </div>
      
      <!-- 服务模块区域 -->
      <div class="services-section">
        <div class="services-grid">
          <router-link to="/service1" class="service-item">
            <div class="service-icon">{{ $t('Medical_Service_service1') }}</div>
            <div class="service-name">{{ $t('Medical_Service_service1') }}</div>
            <div class="service-desc">{{ $t('Medical_Service_service1_desc') }}</div>
          </router-link>
          <router-link to="/service2" class="service-item">
            <div class="service-icon">{{ $t('Medical_Service_service2') }}</div>
            <div class="service-name">{{ $t('Medical_Service_service2') }}</div>
            <div class="service-desc">{{ $t('Medical_Service_service2_desc') }}</div>
          </router-link>
          <router-link to="/service3" class="service-item">
            <div class="service-icon">{{ $t('Medical_Service_service3') }}</div>
            <div class="service-name">{{ $t('Medical_Service_service3') }}</div>
            <div class="service-desc">{{ $t('Medical_Service_service3_desc') }}</div>
          </router-link>
          <router-link to="/service4" class="service-item">
            <div class="service-icon">{{ $t('Medical_Service_service4') }}</div>
            <div class="service-name">{{ $t('Medical_Service_service4') }}</div>
            <div class="service-desc">{{ $t('Medical_Service_service4_desc') }}</div>
          </router-link>
        </div>
      </div>
      
      <!-- 医药相关外部链接区域 -->
      <div class="partners-section">
        <div class="partners-content">
          <div class="partners-title">{{ $t('Medical_Service_health_title') }}</div>
          <div class="partners-links">
            <div class="link-group">
              <a href="https://www.health.com" class="partner-link" target="_blank">
                <div class="partner-icon">{{ $t('Medical_Service_health1') }}</div>
                <div class="partner-name">{{ $t('Medical_Service_health1') }}</div>
                <div class="partner-desc">{{ $t('Medical_Service_health1_desc') }}</div>
              </a>
              <a href="https://www.doctor.com" class="partner-link" target="_blank">
                <div class="partner-icon">{{ $t('Medical_Service_health2') }}</div>
                <div class="partner-name">{{ $t('Medical_Service_health2') }}</div>
                <div class="partner-desc">{{ $t('Medical_Service_health2_desc') }}</div>
              </a>
              <a href="https://www.medicine.com" class="partner-link" target="_blank">
                <div class="partner-icon">{{ $t('Medical_Service_health3') }}</div>
                <div class="partner-name">{{ $t('Medical_Service_health3') }}</div>
                <div class="partner-desc">{{ $t('Medical_Service_health3_desc') }}</div>
              </a>
            </div>
            <div class="link-group">
              <a href="https://www.fitness.com" class="partner-link" target="_blank">
                <div class="partner-icon">{{ $t('Medical_Service_health4') }}</div>
                <div class="partner-name">{{ $t('Medical_Service_health4') }}</div>
                <div class="partner-desc">{{ $t('Medical_Service_health4_desc') }}</div>
              </a>
              <a href="https://www.nutrition.com" class="partner-link" target="_blank">
                <div class="partner-icon">{{ $t('Medical_Service_health5') }}</div>
                <div class="partner-name">{{ $t('Medical_Service_health5') }}</div>
                <div class="partner-desc">{{ $t('Medical_Service_health5_desc') }}</div>
              </a>
              <a href="https://www.mentalhealth.com" class="partner-link" target="_blank">
                <div class="partner-icon">{{ $t('Medical_Service_health6') }}</div>
                <div class="partner-name">{{ $t('Medical_Service_health6') }}</div>
                <div class="partner-desc">{{ $t('Medical_Service_health6_desc') }}</div>
              </a>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      activeIndex: 0,
      interval: null,
      carouselImages: [
        require('@/assets/carousel1.jpg'),
        require('@/assets/carousel2.jpg'),
        require('@/assets/carousel3.jpg'),
      ],
    };
  },
  methods: {
    startCarousel() {
      this.interval = setInterval(this.nextSlide, 5000);
    },
    stopCarousel() {
      clearInterval(this.interval);
      this.interval = null;
    }
  },
  mounted() {
    this.startCarousel();
  },
  beforeDestroy() {
    this.stopCarousel();
  }
};
</script>

<style scoped>
/* 主容器样式 - 调整为与个人消息页面一致 */
.main-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(74, 175, 254, 0.1);
  max-width: 1200px;
  margin: 2rem auto;
  border: 1px solid #e3f2fd;
  position: relative;
  overflow: hidden;
}

.main-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  background: linear-gradient(to bottom, #4f8bf9, #2ac9e6);
}

/* 内容容器样式 */
.content-container {
  display: flex;
  flex-direction: column;
  padding: 20px;
}

/* 轮播图区域 - 调整为与个人消息页面一致 */
.carousel-section {
  margin: 40px 0;
  position: relative;
  height: 400px;
  overflow: hidden;
  border-radius: 15px;
  box-shadow: 0 8px 25px rgba(26, 115, 232, 0.1);
  border: 1px solid #e3f2fd;
}

.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n+1) {
  background-color: #d3dce6;
}

.carousel-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

/* 服务模块样式 - 调整为与个人消息页面一致 */
.services-section {
  background-color: white;
  padding: 40px;
  margin: 40px 0;
  border-radius: 15px;
  box-shadow: 0 8px 25px rgba(26, 115, 232, 0.1);
  border: 1px solid #e3f2fd;
}

.services-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.service-item {
  height: 200px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: #e9f2fe;
  color: #2c3e50;
  font-weight: bold;
  text-decoration: none;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(26, 115, 232, 0.1);
  border: 1px solid #e3f2fd;
}

.service-item:hover {
  background-color: #d6e6fe;
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(26, 115, 232, 0.15);
}

.service-icon {
  font-size: 30px;
  margin-bottom: 15px;
}

.service-name {
  font-size: 18px;
  margin-bottom: 10px;
}

.service-desc {
  font-size: 14px;
  color: #555;
  text-align: center;
}

/* 医药相关外部链接样式 - 调整为与个人消息页面一致 */
.partners-section {
  background-color: white;
  padding: 40px;
  border-radius: 15px;
  box-shadow: 0 8px 25px rgba(26, 115, 232, 0.1);
  border: 1px solid #e3f2fd;
}

.partners-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.partners-title {
  font-size: 24px;
  color: #2c3e50;
  font-weight: bold;
  margin-bottom: 30px;
  text-align: center;
  padding: 10px 20px;
  border-bottom: 2px solid #e0e0e0;
}

.partners-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.link-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  width: 100%;
  margin-bottom: 30px;
}

.partner-link {
  color: #3498db;
  text-decoration: none;
  font-weight: 500;
  padding: 20px;
  border-radius: 10px;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  background-color: #f8f9fa;
  box-shadow: 0 2px 5px rgba(26, 115, 232, 0.1);
  border: 1px solid #e3f2fd;
}

.partner-link:hover {
  background-color: #e1f0fe;
  color: #1a5276;
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(26, 115, 232, 0.15);
}

.partner-icon {
  font-size: 28px;
  margin-bottom: 15px;
}

.partner-name {
  font-size: 16px;
  margin-bottom: 10px;
}

.partner-desc {
  font-size: 14px;
  color: #666;
  text-align: center;
}
</style>